package com.yiyun.blog.controller;

import com.yiyun.blog.service.TagService;
import com.yiyun.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Bao
 * @create 2022-01-09-16:15
 */
@RestController
@RequestMapping("tags")
public class TagsController {

    @Autowired
    TagService tagService;

    // /tag/hot
    @GetMapping("hot")
    public Result hot(){

        //查询最热的三个标签
        int limit = 3;
        return tagService.hot(limit);
    }

    // /tags
    @GetMapping
    public Result findAllTag(){

        return  tagService.findAllTag();
    }

    // /tags/detail
    @GetMapping("detail")
    public Result findAllTagDetail(){

        return  tagService.findAllTagDetail();
    }

    // /tags/detail/{id}
    @GetMapping("detail/{id}")
    public Result findTagDetailById(@PathVariable("id") Long tagId){

        return  tagService.findTagDetailById(tagId);
    }
}
